package com.snfdf.camunda.poollane;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Service;

@Slf4j
@RequiredArgsConstructor
@Service("handleOrder1")
public class HandleOrderService implements JavaDelegate {

    private final RuntimeService runtimeService;

    @Override
    public void execute(DelegateExecution execution) {
        log.info("处理订餐订单");
        String endpoint = (String) execution.getVariable("endpoint");
        // RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
        if (endpoint.equals("alipay")) {
            runtimeService.startProcessInstanceByMessage("Message_alipay_lane");
        } else if (endpoint.equals("wechat")) {
            runtimeService.startProcessInstanceByMessage("Message_wechat_lane");
        }
    }
}
